package cn.vw.hi.commen.manager;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import cn.vw.hi.commen.model.City;
import cn.vw.hi.commen.model.Loads;
import cn.vw.hi.commen.model.Province;
import cn.vw.hi.commen.persistence.DicDao;

public class DicManagerImpl implements DicManager {

	private DicDao dicDao=null;
	//获得省列表
	public List provinceList() {
		return dicDao.provinceList();
	}
	public DicDao getDicDao() {
		return dicDao;
	}
	public void setDicDao(DicDao dicDao) {
		this.dicDao = dicDao;
	}
	//获得市列表
	public List cityList(String provinceId) {
		return dicDao.cityList(provinceId);
	}
	//获得区列表
	public List countiesList(String cityId) {
		return dicDao.countiesList(cityId);
	}
	//添加路
	public boolean addLoad(Loads loads) {
		return dicDao.addLoad(loads);
	}
	//路的列表
	public List loadsList(String provinceId, String cityId, String countiesId) {
		return dicDao.loadsList(provinceId,  cityId,  countiesId);
	}
	//获得路列表 by latlng
	public List loadListByLatLng(String latlng,String searchStr,int radius) {
		return dicDao.loadListByLatLng(latlng,searchStr,radius);
	}
	//查找路
	public Loads findLoads(Integer id) {
		return dicDao.findLoads(id);
	}
	//修改路
	public boolean modifyLoads(Loads loads) {
		return dicDao.modifyLoads(loads);
	}
	//删除路
	public boolean deleteLoads(String ids) {
		return dicDao.deleteLoads(ids);
	}
	//获得城市列表
	@SuppressWarnings("unchecked")
	public Map<String, List<City>> getProvinceCityList() {
       Map<String,List<City>>  mapProvinceCity=new HashMap<String,List<City>>();
		List listProvince=dicDao.provinceList();
		for(Iterator it=listProvince.iterator();it.hasNext();)
		{
			Province provine=(Province)it.next();
			List list=dicDao.cityList(provine.getId());
			mapProvinceCity.put(provine.getId()+"_"+provine.getProvince(),list);
		 }
		return mapProvinceCity;
	}

}
